//
//  TaskDetailModel.m
//  MobileOffice
//
//  Created by jjkj on 16/11/21.
//  Copyright © 2016年 liaoningjujin. All rights reserved.
//

#import "TaskDetailModel.h"

@implementation TaskDetailModel
- (instancetype)initWithResponse:(id)responseObject{
    if (self=[super init]) {
        if ([responseObject[@"code"] isKindOfClass:[NSNumber class]]) {
            NSNumber *num =responseObject[@"code"] ;
            NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
            
            NSString* str = [numberFormatter stringFromNumber:num];
            
            self.code=str?str:@"";
        }else{
            self.code=responseObject[@"code"]?responseObject[@"code"]:@"";
        }
        
        self.msg=responseObject[@"msg"]?responseObject[@"msg"]:@"";
        self.dataArr=[NSMutableArray new];
        NSDictionary *dataDict=responseObject[@"retContent"];
        NSArray *approveCourseList=dataDict[@"approveCourseList"];
        [self setValuesForKeysWithDictionary:dataDict];
        for (NSDictionary *approveCourseListDict in approveCourseList) {
            TaskDetailModel *model=[TaskDetailModel new];
            [model setValuesForKeysWithDictionary:approveCourseListDict];
            model.eliminateApproveList=[NSMutableArray new];
            NSArray *eliminateApproveList=approveCourseListDict[@"eliminateApproveList"];
            for (NSDictionary *eliminateApproveListDict in eliminateApproveList) {
                TaskDetailModel *newmodel=[TaskDetailModel new];
                [newmodel setValuesForKeysWithDictionary:eliminateApproveListDict];
                [model.eliminateApproveList addObject:newmodel];
            }
            
            model.workEntrustList=[NSMutableArray new];
            NSArray *workEntrustList=approveCourseListDict[@"workEntrustList"];
            for (NSDictionary *workEntrustListDict in workEntrustList) {
                TaskDetailModel *newmodel=[TaskDetailModel new];
                [newmodel setValuesForKeysWithDictionary:workEntrustListDict];
                [model.workEntrustList addObject:newmodel];
            }
            [self.dataArr addObject:model];
            
        }
    }
    
    return self;
}
@end
